<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('建立订单')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <div class="row">
            <form class="form-horizontal m" id="form-order-add">
                <div class="col-sm-4" style="width: 50%;">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>订单信息</h5>
                        </div>
                        <div class="ibox-content">
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">提验人：</label>
                                <div class="col-sm-8">
                                    <input name="vehicleInspector" class="form-control" type="text" placeholder="请填写提验人">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">业务员：</label>
                                <div class="col-sm-8">
                                    <select name="userName" class="form-control">
                                        <option>--请选择业务员--</option>
                                        <option th:each="user:${userList}" th:value="${user.userName}+','+${user.phonenumber}" th:text="${user.userName}"></option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">车型：</label>
                                <div class="col-sm-8">
                                    <input name="vehicleModel" class="form-control" type="text" placeholder="请输入车型" required>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">车架号：</label>
                                <div class="col-sm-8">
                                    <input name="vin" class="form-control" type="text" placeholder="请输入车架号" required>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">委托人：</label>
                                <div class="col-sm-8">
                                    <input name="client" class="form-control" type="text" placeholder="请输入委托人">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">委托人电话：</label>
                                <div class="col-sm-8">
                                    <input name="clientPhone" class="form-control" type="number" placeholder="请输入委托人电话">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">起始地：</label>
                                <div class="col-sm-8">
                                    <input name="origin" class="form-control" type="text" placeholder="请输入起始地" required>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">目的地：</label>
                                <div class="col-sm-8">
                                    <input name="dest" class="form-control" type="text" placeholder="请输入目的地" required>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">接车人：</label>
                                <div class="col-sm-8">
                                    <input name="receiver" class="form-control" type="text" placeholder="请输入接车人">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">接车人电话：</label>
                                <div class="col-sm-8">
                                    <input name="receiverPhone" class="form-control" type="text" placeholder="请输入接车人电话">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">支付类型：</label>
                                <div class="col-sm-8">
                                    <div class="radio-box" th:each="dict : ${@dict.getType('pay_type')}">
                                        <input type="radio" th:id="${dict.dictCode}" name="payType" th:value="${dict.dictValue}" th:checked="${dict.default}">
                                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label is-required">运费金额：</label>
                                <div class="col-sm-8">
                                    <input name="freightAmount" class="form-control" type="number" value="0" placeholder="请输入运费金额" required>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">预付款：</label>
                                <div class="col-sm-8">
                                    <input name="paidAmount" class="form-control" type="number" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">备注：</label>
                                <div class="col-sm-8">
                                    <input name="notes" class="form-control" type="text">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">中介费：</label>
                                <div class="col-sm-8">
                                    <input name="agencyFee" class="form-control" type="number" min="0" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">提验费：</label>
                                <div class="col-sm-8">
                                    <input name="inspectionFee" class="form-control" type="number" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">代驾费：</label>
                                <div class="col-sm-8">
                                    <input name="drivingFee" class="form-control" type="number" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">加油费：</label>
                                <div class="col-sm-8">
                                    <input name="refuelingFee" class="form-control" type="number" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">小板费：</label>
                                <div class="col-sm-8">
                                    <input name="smallBoardFee" class="form-control" type="number" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">叉车费：</label>
                                <div class="col-sm-8">
                                    <input name="forkliftFee" class="form-control" type="number" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">保险费：</label>
                                <div class="col-sm-8">
                                    <input name="agencyFee" class="form-control" type="number" min="0" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">洗车费：</label>
                                <div class="col-sm-8">
                                    <input name="agencyFee" class="form-control" type="number" min="0" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">质损费：</label>
                                <div class="col-sm-8">
                                    <input name="agencyFee" class="form-control" type="number" min="0" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">中转落站：</label>
                                <div class="col-sm-8">
                                    <input name="agencyFee" class="form-control" type="number" min="0" value="0">
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom:2px;">
                                <label class="col-sm-3 control-label">其他费：</label>
                                <div class="col-sm-8">
                                    <input name="agencyFee" class="form-control" type="number" min="0" value="0">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4" style="width: 50%;">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>图片</h5>
                        </div>
                        <div class="ibox-content">
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-required">汽车图片地址：</label>
                                <div class="col-sm-8">
                                    <input type="hidden" id="carImgs" name="carImgs">
                                    <div class="file-loading">
                                        <input class="form-control file-upload" name="files" type="file" multiple>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-required">合同图片地址：</label>
                                <div class="col-sm-8">
                                    <input type="hidden" id="contractImgs" name="contractImgs">
                                    <div class="file-loading">
                                        <input class="form-control file-upload" name="files" type="file" multiple>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

<!--            <h4 class="form-header h4">货运中转信息</h4>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-12">-->
<!--                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>-->
<!--                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>-->
<!--                    <div class="col-sm-12 select-table table-striped">-->
<!--                        <table id="bootstrap-table"></table>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
        </form>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/order"
        $("#form-order-add").validate({
            focusCleanup: true
        });
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-order-add').serialize());
            }
        }

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/uploads',
            uploadAsync: false
        }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
            console.log(data.response.urls+"-----"+event.currentTarget.carImgs);
            var carImgs = $("#carImgs").val();
            if(carImgs == null || carImgs == ""){
                $("#carImgs").val(data.response.urls);
            }else {
                $("#contractImgs").val(data.response.urls);
            }
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })

        // $(function() {
        //     var options = {
        //         pagination: false,
        //         showSearch: false,
        //         showRefresh: false,
        //         showToggle: false,
        //         showColumns: false,
        //         sidePagination: "client",
        //         columns: [{
        //             checkbox: true
        //         },
        //         {
        //             field: 'index',
        //             align: 'center',
        //             title: "序号",
        //             formatter: function (value, row, index) {
        //             	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
        //             	return columnIndex + $.table.serialNumber(index);
        //             }
        //         },
        //         {
        //             field: 'name',
        //             align: 'center',
        //             title: '中转段',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].name' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'transitBranch',
        //             align: 'center',
        //             title: '中转分公司',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transitBranch' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'headPhone',
        //             align: 'center',
        //             title: '分公司负责人',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].headPhone' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'transporter',
        //             align: 'center',
        //             title: '运输人',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transporter' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'transporterPhone',
        //             align: 'center',
        //             title: '运输人电话',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transporterPhone' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'amount',
        //             align: 'center',
        //             title: '到收费用',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].amount' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'owes',
        //             align: 'center',
        //             title: '欠反',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].owes' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'transferFee',
        //             align: 'center',
        //             title: '中转费',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transferFee' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'state',
        //             align: 'center',
        //             title: '结清状态',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].state' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'notes',
        //             align: 'center',
        //             title: '备注',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].notes' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'updateTime',
        //             align: 'center',
        //             title: '更新时间',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].updateTime' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             field: 'createTime',
        //             align: 'center',
        //             title: '创建时间',
        //             formatter: function(value, row, index) {
        //                 var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].createTime' value='%s'>", index, value);
        //                 return html;
        //             }
        //         },
        //         {
        //             title: '操作',
        //             align: 'center',
        //             formatter: function(value, row, index) {
        //                 var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
        //                 return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
        //             }
        //         }]
        //     };
        //     $.table.init(options);
        // });

        // function addRow() {
        //     var count = $("#" + table.options.id).bootstrapTable('getData').length;
        //     var row = {
        //         index: $.table.serialNumber(count),
        //         name: "",
        //         transitBranch: "",
        //         headPhone: "",
        //         transporter: "",
        //         transporterPhone: "",
        //         amount: "",
        //         owes: "",
        //         transferFee: "",
        //         state: "",
        //         notes: "",
        //         updateTime: "",
        //         createTime: "",
        //     }
        //     sub.addRow(row);
        // }
    </script>
</body>
</html>